package com.muyu.product.service.impl;

import java.util.List;

import com.muyu.common.core.utils.ObjUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import com.muyu.product.mapper.CommentInfoMapper;
import com.muyu.product.domain.CommentInfo;
import com.muyu.product.service.CommentInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

/**
 * 商品评论Service业务层处理
 *
 * @author DongZeLiang
 * @date 2024-02-27
 */
@Slf4j
@Service
public class CommentInfoServiceImpl extends ServiceImpl<CommentInfoMapper, CommentInfo>  implements CommentInfoService {

    /**
     * 查询商品评论列表
     *
     * @param commentInfo 商品评论
     * @return 商品评论
     */
    @Override
    public List<CommentInfo> list(CommentInfo commentInfo) {
        LambdaQueryWrapper<CommentInfo> queryWrapper = new LambdaQueryWrapper<>();


        if (ObjUtils.notNull(commentInfo.getProjectId())){
            queryWrapper.eq(CommentInfo::getProjectId, commentInfo.getProjectId());
        }

        if (ObjUtils.notNull(commentInfo.getComment())){
            queryWrapper.eq(CommentInfo::getComment, commentInfo.getComment());
        }

        if (ObjUtils.notNull(commentInfo.getImages())){
            queryWrapper.eq(CommentInfo::getImages, commentInfo.getImages());
        }

        if (ObjUtils.notNull(commentInfo.getParentId())){
            queryWrapper.eq(CommentInfo::getParentId, commentInfo.getParentId());
        }





        return list(queryWrapper);
    }
}
